box = GTK_BOX (container);
private = box->priv;
- path = gtk_widget_path_copy (gtk_widget_get_path (GTK_WIDGET (container)));
+ path = _gtk_widget_create_path (GTK_WIDGET (container));
if (gtk_widget_get_visible (child))
{
GtkWidgetPath *sibling_path;
int pos;
- path = gtk_widget_path_copy (gtk_widget_get_path (GTK_WIDGET (container)));
+ path = _gtk_widget_create_path (GTK_WIDGET (container));
if (gtk_widget_get_visible (child))
{
GList *classes;
context = gtk_widget_get_style_context (GTK_WIDGET (container));
- path = gtk_widget_path_copy (gtk_widget_get_path (GTK_WIDGET (container)));
+ path = _gtk_widget_create_path (GTK_WIDGET (container));
/* Copy any permanent classes to the path */
classes = gtk_style_context_list_classes (context);
context = gtk_style_context_new ();
/* Create a GtkCheckMenuItem path, only to query indicator spacing */
- check_path = gtk_widget_path_copy (gtk_widget_get_path (widget));
+ check_path = _gtk_widget_create_path (widget);
gtk_widget_path_append_type (check_path, GTK_TYPE_CHECK_MENU_ITEM);
gtk_style_context_set_path (context, check_path);
GtkPathBar *path_bar = GTK_PATH_BAR (container);
GtkWidgetPath *path;
- path = gtk_widget_path_copy (gtk_widget_get_path (GTK_WIDGET (path_bar)));
+ path = _gtk_widget_create_path (GTK_WIDGET (path_bar));
if (gtk_widget_get_visible (child) &&
gtk_widget_get_child_visible (child))
#include "gtkstock.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetpath.h"
+#include "gtkwidgetprivate.h"
#include "a11y/gtkspinbuttonaccessible.h"
* have to emulate what gtk_container_get_path_for_child() would do
* for the button panels
*/
- path = gtk_widget_path_copy (gtk_widget_get_path (widget));
+ path = _gtk_widget_create_path (widget);
direction = gtk_widget_get_direction (widget);
siblings_path = gtk_widget_path_new ();
guint i, pos;
priv = context->priv;
- path = gtk_widget_path_copy (priv->widget ? gtk_widget_get_path (priv->widget) : priv->widget_path);
+ path = priv->widget ? _gtk_widget_create_path (priv->widget) : gtk_widget_path_copy (priv->widget_path);
pos = gtk_widget_path_length (path) - 1;
info = priv->info_stack->data;
if (priv->widget || priv->widget_path)
{
+ GtkWidgetPath *widget_path = priv->widget ? _gtk_widget_create_path (priv->widget) : priv->widget_path;
+
if (gtk_style_provider_get_style_property (GTK_STYLE_PROVIDER (priv->cascade),
- priv->widget ? gtk_widget_get_path (priv->widget)
- : priv->widget_path,
+ widget_path,
state, pspec, &pcache->value))
{
/* Resolve symbolic colors to GdkColor/GdkRGBA */
gtk_symbolic_color_unref (color);
}
+ if (priv->widget)
+ gtk_widget_path_free (widget_path);
+
return &pcache->value;
}
+
+ if (priv->widget)
+ gtk_widget_path_free (widget_path);
}
/* not supplied by any provider, revert to default */
g_list_foreach (children, add_widget_to_path, sibling_path);
g_list_free (children);
- path = gtk_widget_path_copy (gtk_widget_get_path (GTK_WIDGET (container)));
+ path = _gtk_widget_create_path (GTK_WIDGET (container));
if (gtk_widget_get_visible (child))
{
vis_index = gtk_toolbar_get_visible_position (toolbar, child);
return pos;
}
+GtkWidgetPath *
+_gtk_widget_create_path (GtkWidget *widget)
+{
+ GtkWidget *parent;
+
+ parent = widget->priv->parent;
+
+ if (parent)
+ return gtk_container_get_path_for_child (GTK_CONTAINER (parent), widget);
+ else
+ {
+ /* Widget is either toplevel or unparented, treat both
+ * as toplevels style wise, since there are situations
+ * where style properties might be retrieved on that
+ * situation.
+ */
+ GtkWidget *attach_widget = NULL;
+ GtkWidgetPath *result;
+
+ if (GTK_IS_WINDOW (widget))
+ attach_widget = gtk_window_get_attached_to (GTK_WINDOW (widget));
+
+ if (attach_widget != NULL)
+ result = gtk_widget_path_copy (gtk_widget_get_path (attach_widget));
+ else
+ result = gtk_widget_path_new ();
+
+ gtk_widget_path_append_for_widget (result, widget);
+
+ return result;
+ }
+}
+
/**
* gtk_widget_get_path:
* @widget: a #GtkWidget
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
if (!widget->priv->path)
- {
- GtkWidget *parent;
-
- parent = widget->priv->parent;
-
- if (parent)
- widget->priv->path = gtk_container_get_path_for_child (GTK_CONTAINER (parent), widget);
- else
- {
- /* Widget is either toplevel or unparented, treat both
- * as toplevels style wise, since there are situations
- * where style properties might be retrieved on that
- * situation.
- */
- GtkWidget *attach_widget = NULL;
-
- if (GTK_IS_WINDOW (widget))
- attach_widget = gtk_window_get_attached_to (GTK_WINDOW (widget));
-
- if (attach_widget != NULL)
- widget->priv->path = gtk_widget_path_copy (gtk_widget_get_path (attach_widget));
- else
- widget->priv->path = gtk_widget_path_new ();
-
- gtk_widget_path_append_for_widget (widget->priv->path, widget);
- }
- }
+ widget->priv->path = _gtk_widget_create_path (widget);
return widget->priv->path;
}
gboolean _gtk_widget_captured_event (GtkWidget *widget,
GdkEvent *event);
+GtkWidgetPath * _gtk_widget_create_path (GtkWidget *widget);
void _gtk_widget_invalidate_style_context (GtkWidget *widget,
GtkCssChange change);
void _gtk_widget_style_context_invalidated (GtkWidget *widget);